package jianli;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebServlet("/ShowSession")
public class ShowSession extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public ShowSession() {
        super();
    }                
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ 
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<body>");
        HttpSession session=request.getSession(); //获得Session对象
        String id=session.getId();//取得sessionID
        String name=(String)session.getAttribute("username");  //获取session范围内保存的username
        out.println("session信息<br/>id:"+id+"<br/>name:"+name);
        response.setHeader("refresh","5;URL=jianli.jsp");//定时跳转
        String s1="<h3>用户登录成功，5秒后跳转到简历填写页面!</h3><br>";
        String s2="<h3>如果没有跳转，请按<a href='jianli.jsp'>这里</a></h3>";
        out.println(s1+s2);
        out.println("</body>");
        out.println("</html>");
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}